package com.linciping.gradle.methodcodeinject

import com.android.build.gradle.AppExtension
import org.gradle.api.Plugin
import org.gradle.api.Project

class MethodCodeInjectPlugin : Plugin<Project> {
    override fun apply(project: Project) {
        try {
            val appExtension = project.extensions.getByType(AppExtension::class.java)
            val methodCodeExtension = MethodCodeExtension()
            project.extensions.add(MethodCodeExtension::class.java, "methodCode", methodCodeExtension)
            appExtension.registerTransform(MethodCodeTransform(methodCodeExtension,project))
        } catch (ex: Exception) {
            println("project no app module")
        }
    }
}